package com.xgg.taiwuinfo.filter.fc;

import android.content.Context;
import android.util.Log;

import com.xgg.taiwuinfo.R;
import com.xgg.taiwuinfo.filter.FC_EqualSelect;
import com.xgg.taiwuinfo.filter.FilterComponent;
import com.xgg.taiwuinfo.gongfa.base.Gongfa;
import com.xgg.taiwuinfo.utils.Inherit;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FCInheritEqualSelect extends FC_EqualSelect {

    public FCInheritEqualSelect(JSONObject obj , Context ctx)
    {
        mTypeId = FilterComponent.FT_INHERIT_EQUAL_SELECT;
        if (obj != null) {
            try {
                ReadValue = obj.getInt("v");
                ReadCompare = obj.getInt("c");
            } catch (Exception e) {
                Log.d("LoadJson", e.getLocalizedMessage());
                ReadValue = Inherit.INHERIT_NONE;
                ReadCompare = FC_EQUAL;
            }
        }
        else {
            ReadValue = Inherit.INHERIT_NONE;
            ReadCompare = FC_EQUAL;
        }
        TempValue = ReadValue;
        TempCompare = ReadCompare;

        FieldStr = "功法门派";
        if (mValueMap == null) {
            mValueMap = new ArrayList<>();
            Map<String, String> map;

            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_none));
            map.put("v", Inherit.INHERIT_NONE + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_shaolin));
            map.put("v", Inherit.INHERIT_SHAOLIN + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_shixiang));
            map.put("v", Inherit.INHERIT_SHIXIANG + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_jingang));
            map.put("v", Inherit.INHERIT_JINGANG + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_emei));
            map.put("v", Inherit.INHERIT_EMEI + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_ranshan));
            map.put("v", Inherit.INHERIT_RANSHAN + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_wuxian));
            map.put("v", Inherit.INHERIT_WUXIAN + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_baihua));
            map.put("v", Inherit.INHERIT_BAIHUA + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_xuannv));
            map.put("v", Inherit.INHERIT_XUANNV + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_jieqing));
            map.put("v", Inherit.INHERIT_JIEQING + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_wudang));
            map.put("v", Inherit.INHERIT_WUDANG + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_zhujian));
            map.put("v", Inherit.INHERIT_ZHUJIAN + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_fulong));
            map.put("v", Inherit.INHERIT_FULONG + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_yuanshan));
            map.put("v", Inherit.INHERIT_YUANSHAN + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_kongsang));
            map.put("v", Inherit.INHERIT_KONGSANG + "");
            mValueMap.add(map);
            map = new HashMap<>();
            map.put("f", ctx.getString(R.string.inherit_xuehou));
            map.put("v", Inherit.INHERIT_XUEHOU + "");
            mValueMap.add(map);
        }
    }

    @Override
    public String FilterGongfa(Gongfa gongfa){
        if (gongfa.mInherit == ReadValue ^ !(ReadCompare == FC_EQUAL))
        {
            return "";
        }
        else
            return null;
    }

    @Override
    public List<Map<String, String>> getFieldString(Context ctx){
        List<Map<String, String>> mCompMap = new ArrayList<>();
        Map<String, String> map;

        map = new HashMap<>();
        map.put("f", FieldStr);
        map.put("v",   "0");
        mCompMap.add(map);

        return mCompMap;
    }

    @Override
    public List<Map<String, String>> getValueMap(Context ctx)
    {
        return mValueMap;
    }



}
